// pages/address/address.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        myAddress:[
            {
                id:0,
                name:"蒋先生",
                phone:"15335468951",
                bigAddress:"广东省广州市天河区珠吉街道",
                detAddress:"珠吉路60号粤嵌科技产业园",
                defult:true
            },
            {
                id:1,
                name:"李小姐",
                phone:"13435468962",
                bigAddress:"广东省广州市天河区珠吉街道",
                detAddress:"珠吉路59号粤嵌科技产业园",
                defult:false
            },
            {
                id:2,
                name:"王先生",
                phone:"18355468978",
                bigAddress:"广东省广州市天河区珠吉街道",
                detAddress:"珠吉路61号粤嵌科技产业园",
                defult:false
            }
        ]
    },
   

    setDefult(options){
        console.log(options);
        let nowId = options.currentTarget.dataset.ind.id;
        let myAddress = wx.getStorageSync("myAddress");
        myAddress.forEach(item=>{
            console.log(item);
            item.defult = false;
        })
        myAddress[nowId].defult = true;
        wx.setStorageSync('myAddress', myAddress);
        this.setData({myAddress})

    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        let myStorage = wx.getStorageSync("myAddress");
        // console.log(myStorage);
        let myAddress = this.data.myAddress;
        if(myStorage.length>=1){
            this.setData({myAddress:myStorage})
        }else{
            wx.setStorageSync('myAddress', myAddress)
        }
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})